package jiuxing

type TimeSegRate struct {
	BeginHour     byte
	BeginMinute   byte
	Tp            byte
	ElectricRate  uint32
	ServiceCharge uint32
}

type BillMode struct {
	Ver          uint16
	ParkRate     uint32
	TimeSegNum   byte
	TimeSegRates []TimeSegRate
}

func (bm *BillMode) Encode() []byte {
	ret := []byte{}
	ret = append(ret, Int16ToBytes(int16(bm.Ver))...)
	ret = append(ret, IntToBytes(int(bm.ParkRate))...)
	ret = append(ret, bm.TimeSegNum)
	for i := 0; i < int(bm.TimeSegNum); i++ {
		ret = append(ret, bm.TimeSegRates[i].BeginHour)
		ret = append(ret, bm.TimeSegRates[i].BeginMinute)
		ret = append(ret, bm.TimeSegRates[i].Tp)
		ret = append(ret, IntToBytes(int(bm.TimeSegRates[i].ElectricRate))...)
		ret = append(ret, IntToBytes(int(bm.TimeSegRates[i].ServiceCharge))...)
	}
	return ret
}

func (bm *BillMode) Decode(b []byte) {
	// item := NewByteArray(b)
	// bm.Ver = item.GetUint16(0)
	// bm.ParkRate = item.GetUint32(2)
	// bm.TimeSegNum = item.GetUint8(6)
	// for i := 0; i < int(bm.TimeSegNum); i++ {
	// 	tmSegRate := TimeSegRate{
	// 		BeginHour:     item.ByteArray(7+11*i, 2),
	// 		Tp:            item.GetUint8(7 + 11*i + 2),
	// 		ElectricRate:  item.GetUint32(7 + 11*i + 3),
	// 		ServiceCharge: item.GetUint32(7 + 11*i + 7),
	// 	}
	// 	bm.TimeSegRates = append(bm.TimeSegRates, tmSegRate)
	// }
}

var chargeBill struct {
}
